load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "split",
    srcs = [
        "client.go",
        "mock_pd_client.go",
        "region.go",
        "split.go",
    ],
    importpath = "github.com/pingcap/tidb/br/pkg/restore/split",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/conn/util",
        "//br/pkg/errors",
        "//br/pkg/logutil",
        "//br/pkg/utils",
        "//pkg/kv",
        "//pkg/lightning/common",
        "//pkg/lightning/config",
        "//pkg/lightning/log",
        "//pkg/store/pdtypes",
        "//pkg/util",
        "//pkg/util/codec",
        "//pkg/util/intest",
        "//pkg/util/redact",
        "@com_github_docker_go_units//:go-units",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/errorpb",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_kvproto//pkg/pdpb",
        "@com_github_pingcap_kvproto//pkg/tikvpb",
        "@com_github_pingcap_log//:log",
        "@com_github_tikv_pd_client//:client",
        "@com_github_tikv_pd_client//http",
        "@org_golang_google_grpc//:grpc",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//credentials",
        "@org_golang_google_grpc//credentials/insecure",
        "@org_golang_google_grpc//status",
        "@org_golang_x_sync//errgroup",
        "@org_uber_go_multierr//:multierr",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "split_test",
    timeout = "short",
    srcs = [
        "client_test.go",
        "split_test.go",
    ],
    embed = [":split"],
    flaky = True,
    shard_count = 19,
    deps = [
        "//br/pkg/errors",
        "//br/pkg/utils",
        "//pkg/kv",
        "//pkg/sessionctx/stmtctx",
        "//pkg/store/pdtypes",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util/codec",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_kvproto//pkg/pdpb",
        "@com_github_stretchr_testify//require",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//status",
    ],
)
